a = input().split()
num = ' '

for i in a:
    if i == 'zero':
        num += '0'
    if i == 'one':
        num += '1'
    if i == 'two':
        num += '2'
    if i == 'three':
        num += '3'
    if i == 'four':
        num += '4'
    if i == 'five':
        num += '5'
    if i == 'six':
        num += '6'
    if i == 'seven':
        num += '7'
    if i == 'eight':
        num += '8'
    if i == 'nine':
        num += '9'


def is_prime(x):
    if not x % 2:
        return x == 2
    p = 3
    while p * p <= x and x % p:
        p+= 2
    return p * p > x


b = int(num)

if 99 < b < 1000:
    tmp = abs(b - 2)
    res = 2
    k = 3
    while True:
        if is_prime(k):
            t = abs(b - k)
            if t < tmp:
                tmp = t
                res = k
            else:
                print(res)
                break
        k += 2
else:
    print('Wrong input') 
